/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ep.m006.ui.controllers;

import com.vaadin.data.util.BeanItemContainer;
import ep.libs.implementations.AbstractModule;
import ep.m006.bl.BL006Controller;
import ep.persistence.entities.T005Patient;
import ep.persistence.entities.T006Prescription;
import ep.persistence.entities.T008Dosage;

/**
 *
 * @author Spyros
 */
public class M006Controller {

    T005Patient patient;
    BL006Controller bL006Controller;

    public M006Controller(Object patientObject, AbstractModule module) {
        this.patient = (T005Patient) patientObject;
        bL006Controller = new BL006Controller();

    }

    public BeanItemContainer<T006Prescription> getFinalizedPrescDataSource() {
        BeanItemContainer<T006Prescription> beanItemContainer =
                new BeanItemContainer<T006Prescription>(
                T006Prescription.class,
                bL006Controller.getFinalizedPrescritions(patient.getId()));
        return beanItemContainer;
    }

    public BeanItemContainer<T006Prescription> getPendingPrescDataSource() {
        BeanItemContainer<T006Prescription> beanItemContainer =
                new BeanItemContainer<T006Prescription>(
                T006Prescription.class,
                bL006Controller.getUnprescripedPrescriptions(patient.getId()));
        return beanItemContainer;
    }

    public T005Patient getPatient() {
        return patient;
    }

    public Integer getPrescriptionId(Object prescObject) {
        T006Prescription prescription = (T006Prescription) prescObject;
        return prescription.getId();
    }

}
